﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Filters;
using PMS.ENT;

namespace PMS.BLL
{
    public class CustomLogFilter
    {
        public static int SeverityFilter;

        public bool Filter(int? priority, bool logEnabled)
        {
            PriorityFilter priorityFilter = new PriorityFilter("Priority", SeverityFilter);
            LogEnabledFilter logEnabledFilter = new LogEnabledFilter("LogEnabled Filter", logEnabled);

            if (logEnabledFilter.Enabled == true)
            {
                if (priority == null || priorityFilter.ShouldLog(priority.Value))
                    return true;
                else
                    return false;
            }
            else
                return false;
        }
    }
}
